Read-eval-print loops

The user usually interacts with the T system via a read-eval-print loop. As illustrated above, this is a command loop which repeatedly reads an expression, evaluates it, and prints the value.

The read-eval-print loop is a simple command processor; it prints a prompt, reads a command from the terminal, executes the command, then prints another prompt, ad infinitum. A command is any executable T form, and executing the command consists of evaluating the form and printing the result.


\begin{inset}{}
The variable {\tt\char93 \char93 } always has as its value the l...
...t loop, that is, the value
of the last expression typed by the user.
\end{inset}


\begin{inset}{}
{\bf Removed in {\bf T3}.}
The variable {\tt ++} always has as i...
...n evaluated, so that a new expression may refer to
the previous one.
\end{inset}

Expressions are read from the terminal by applying the READ operation (actually, the value of (REPL-READ); see page [*]) to the terminal input port. Initially, that port's read table is the standard read table, but this may be changed using SET, for example:
\begin{codexenv}
(SET (PORT-READ-TABLE (TERMINAL-INPUT)) *MY-READ-TABLE*)
\end{codexenv}

Evaluation is performed with respect to a particular variable environment and its syntax table. The read-eval-print loop may move from place to place within the environment hierarchy; one may control the evaluation environment and syntax table by setting (REPL-ENV).

Settable


\begin{inset}{}
Accesses the environment passed to {\tt (REPL-EVAL)} by the
read...
...ally, this is the scratch environment
(see page \pageref{USER-ENV}).
\end{inset}